<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        /* 使用geojson创建区要素 */
        var polygons = {
            type: 'FeatureCollection',
            features: [
                {
                    type: "Feature",
                    geometry: {
                        type: "Polygon",
                        coordinates: [
                            [
                                [114.30, 30.50],
                                [118, 30.50],
                                [118, 24]
                            ]

                        ]
                    },
                    properties: {
                        id: 10003,
                        name: '区要素'
                    }
                }
            ]
        }
        var ol_features = new ol.format.GeoJSON().readFeatures(polygons);
        const style = new ol.style.Style({
            stroke: new ol.style.Stroke({
                color: "green",
                width: 3
            })
        })
        var source = new ol.source.Vector({
            features: ol_features
        });
        var layer = new ol.layer.Vector(({
            source,
            style,
            /* opacity设置图层的透明度 */
            opacity: 0.5
        }))
        map.addLayer(layer);
    </script>
</body>

</html>